<div id="ajax_upload" style="padding-top: 20px;">
    <form class="upload_form" id="upload_form" name="upload_form" enctype="multipart/form-data" method="post" action="<?php echo base_url('upload/do_upload') ?>" >
        <table cellpadding="1" border="0" style="width:400px;">
            <tbody><tr>
                <td width="120" align="center" valign="middle" style="width:100px;height:100px;vertical-align:middle;border:1px solid #CCC">
                    <img src="http://enbac2.todo.vn/style/images/no-images-69x53.jpg" align="absmiddle" alt="" name="thumb" id="thumb" title="" height="100" width="100">
                </td>
                <td align="left" valign="top" style="padding-left: 10px;">
                    <div style="position: relative">
                        <input type="file" style="" size="42" name="img_upload" id="ufile">
                    </div>
                    <div style="margin-top:5px; margin-bottom:5px;">(jpg, jpeg, gif, png &lt; 2MB)</div>

                    <input type="text" name="url" id="url" onblur="if(this.value==''){ this.value = 'Hoặc Url';}" onclick="if(this.value=='Hoặc Url'){this.value=''}" value="Hoặc Url" style="margin-top: 2px; width: 200px; float: left; background-color: rgb(255, 255, 255);">
                    <img id="loading" src="style/images/uploading.gif" style="float:left;margin-left:6px;display:none">
                    <div style="color:#999;float:left;width:280px;overflow:hidden" id="real_name"></div>
                    <div style="float:left;margin:4px 0 0 0;width:280px">
                        <input type="submit" name="submit" id="submit" value="Submit" />
                        <input type="button" value="Nhập lại" id="cancel" style="cursor:pointer;width:30px;float:left;margin-left:14px;width:80px">
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<script type="text/javascript">
$(document).ready(function(){
    //xu ly upload file
    $("#submit").click(function(){
        $.ajaxFileUpload({
            url : base_url+ "upload/do_upload",
            secureuri : false,
            fileElementId : "ufile",
            dataType :"json",
            data : {
                "title" : $("#title").val()
            },
            success : function(data, status){
                if(data.status != "error"){
                    $("#files").html("<p>Loading....</p>");
                    refresh_files();
                    $("#title").val("");
                }
                alert(data.msg);
            }
        });
        return false;
    }); //ket thuc upload file
});
</script>